package com.fang.study.context;

import com.fang.study.pojo.User;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * @author fanglingxiao
 * @version 1.0
 * @description TODO
 * @date 2021/12/28 2:55 上午
 **/
public class MyBeanPostProcessor implements BeanPostProcessor {


	@Override
	public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
		if (bean instanceof User) {
			System.out.println("---------------");
			System.out.println("MyBeanPostProcessor before invoke,beanName=" + beanName);
			System.out.println("---------------");
		}
		return bean;
	}

	@Override
	public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
		if (bean instanceof User) {
			System.out.println("---------------");
			System.out.println("MyBeanPostProcessor after invoke,beanName=" + beanName);
			System.out.println("---------------");
		}
		return bean;
	}
}
